home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Collections: Scope
/
Scope Disk #058 (199x)(Scope PD)(US)[WB].zip
/
Scope Disk #058 (199x)(Scope PD)(US)[WB].adf
/
AdjClock
/
adjclock.c
< prev
next >
Wrap
C/C++ Source or Header
|
1989-02-28
|
1KB
|
77 lines
#include <stdio.h>
main()
{
int count[7];
char oldval,saveval;
long ticks[6];
int i;
long scount;
char *clock = (char *)0xdc0001;
long SetSignal();
union {
char b[4];
long l;
} t;
long counter=-1,diff;
t.b[0] = 0;
printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
for (i=0; i<6; ++i)
{
count[i] = 0;
ticks[i] = 0;
}
/* wait for the seconds to change */
for (scount = 1000000l,oldval = clock[0];
oldval == clock[0] && --scount;);
if (!scount)
{
printf("No clock\n");
return 0;
}
oldval &= 15;
SetSignal(0l,0x7000l);
while ((0x7000L & SetSignal(0l,0l)) == 0)
{
/* wait for 2 readings with the same value, before I did this I */
/* occasionally got some strange results */
do saveval = clock[0] & 15;
while (saveval == 15 || saveval != (15 & clock[0]));
if (saveval == oldval) continue;
oldval = saveval;
t.b[1] = *(unsigned char *)0xbfea01;
t.b[2] = *(unsigned char *)0xbfe901;
t.b[3] = *(unsigned char *)0xbfe801;
scount = t.l;
diff = (65536l + scount - counter) & 0xffffl;
if (counter == -1)
{
counter = scount;
continue;
}
/* force the first counter to print every second */
count[0] = 10;
counter = scount;
for (i=0; i<6; ++i)
{
ticks[i] += diff;
if (count[i] == 10)
{
printf("\x9b%d;%d\x48%6d ",
15-i,count[i+1]++ * 6+1,ticks[i]);
count[i] = 0;
ticks[i] = 0;
}
}
}
return 0;
}